classdef coiflet

methods(Static)

    function qmf = quad_mirror_filter(parameter)
        % Generates orthonormal quadrature mirror filter for Coiflets
        switch parameter
        case 1
            qmf = [ .038580777748   -.126969125396  -.077161555496  ...
                    .607491641386   .745687558934   .226584265197   ];
       case 2
            qmf = [ .016387336463   -.041464936782  -.067372554722  ...
                    .386110066823   .812723635450   .417005184424   ...
                    -.076488599078  -.059434418646  .023680171947   ...
                    .005611434819   -.001823208871  -.000720549445  ];
        case 3
            qmf = [ -.003793512864  .007782596426   .023452696142   ...
                    -.065771911281  -.061123390003  .405176902410   ...
                    .793777222626   .428483476378   -.071799821619  ...
                    -.082301927106  .034555027573   .015880544864   ...
                    -.009007976137  -.002574517688  .001117518771   ...
                    .000466216960   -.000070983303  -.000034599773  ];
        case 4
            qmf = [ .000892313668   -.001629492013  -.007346166328  ...
                    .016068943964   .026682300156   -.081266699680  ...
                    -.056077313316  .415308407030   .782238930920   ...
                    .434386056491   -.066627474263  -.096220442034  ...
                    .039334427123   .025082261845   -.015211731527  ...
                    -.005658286686  .003751436157   .001266561929   ...
                    -.000589020757  -.000259974552  .000062339034   ...
                    .000031229876   -.000003259680  -.000001784985  ];
        case 5
            qmf = [ -.000212080863  .000358589677   .002178236305   ...
                    -.004159358782  -.010131117538  .023408156762   ...
                    .028168029062   -.091920010549  -.052043163216  ...
                    .421566206729   .774289603740   .437991626228   ...
                    -.062035963906  -.105574208706  .041289208741   ...
                    .032683574283   -.019761779012  -.009164231153  ...
                    .006764185419   .002433373209   -.001662863769  ...
                    -.000638131296  .000302259520   .000140541149   ...
                    -.000041340484  -.000021315014  .000003734597   ...
                    .000002063806   -.000000167408  -.000000095158  ];
        otherwise
            error('Unsupported parameter');
        end
    end


    function wave = wavelet_function(j, k, n, parameter)
        % Makes an orthogonal wavelet function
        %
        % Inputs: 
        %  j, k - scale and location indices
        %  n - signal length (dyadic)
        qmf = spx.wavelet.coiflet.quad_mirror_filter(parameter);
        w = zeros(1, n);
        % identify the index of the j-th scale at k-th translation
        index = spx.wavelet.dyad_to_index(j, k);
        w(index) = 1;         
        wave = spx.wavelet.transform.inverse_periodized_orthogonal(qmf, w, j);
    end

    function wave = scaling_function(j, k, n, parameter)
        % Makes an orthogonal scaling function
        %
        % Inputs: 
        %  j, k - scale and location indices
        %  n - signal length (dyadic)
        qmf = spx.wavelet.coiflet.quad_mirror_filter(parameter);
        w = zeros(1, n);
        % k-th translate in the coarsest part of the wavelet coefficients
        w(k) = 1;
        wave = spx.wavelet.transform.inverse_periodized_orthogonal(qmf, w, j);
    end

end


end
